;GB16 for Chip16
;Shendo 2011
;
;r0 - Logo X coordinate
;r1 - Logo Y coordinate
;r2 - Current logo address
;r3 - Default logo address
;r4 - Maximum Y coordinate
;ra - Number of frames to wait
;
	cls				;Start clean
	spr #0F50			;160x14 px sprite
	ldi r0, 75			;Default logo X coordinate
	ldi r1, 0			;Default logo Y coordinate
	ldi r2, c16_logo		;Load logo address
	ldi r3, c16_logo		;Load logo address
	ldi r4, 100			;Maximum allowed Y offset
	addi r2, 1120			;Increase logo offset (right after logo)
	bgc #A				;Light green background
	ldi ra, 30			;Number of frames to wait
	call wait_frames		;Wait for required number of frames
:start
	vblnk				;Wait for VBlank
	cls				;Clear screen
	bgc #A				;Light green background
	drw r0, r1, r2			;Draw logo on screen
	jme r2, r3, increase_y		;Skip decreasing logo offset if logo is visible
	subi r2, 160			;Decrease logo offset
	jmp start			;Draw new frame
:increase_y
	addi r1, 2			;Increment Y coordinate
	jme r1, r4, play_sound		;Check if max Y has been reached
	jmp start			;Draw new frame
:play_sound
	snd2, 100			;Play 500 Hz sound for 100 ms			
	ldi ra, 5			;Wait 5 frames
	call wait_frames		;Go to wait subroutine
	snd3, 350			;Play 1500 Hz sound for 350 ms
:loop
	jmp loop			;Endless loop
:wait_frames				;Wait for required number of frames
	vblnk				;Wait for VBlank
	subi ra, 1			;Decrement frame counter
	jmz wait_end			;Break the loop
	jmp wait_frames			;Wait for another frame
:wait_end
ret
:c16_logo
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #00
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #00
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #90
db #00
db #09
db #99
db #90
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #99
db #99
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #00
db #09
db #99
db #90
db #00
db #09
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #99
db #00